//
//  YLUserLoginViewController.m
//  YLHelper
//
//  Created by she1323 on 2018/3/26.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "YLUserLoginViewController.h"
#import "LKUserLoginViewModel.h"

@interface YLUserLoginViewController ()

@property (weak, nonatomic) IBOutlet UITextField *usernameTF;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;
@property (weak, nonatomic) IBOutlet UIButton *LoginBtn;
@property(nonatomic,strong) LKUserLoginViewModel *viewModel;

@end

@implementation YLUserLoginViewController

-(LKUserLoginViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[LKUserLoginViewModel alloc] init];
    }
    return _viewModel;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setup];
    [self bindModelView];
    // Do any additional setup after loading the view from its nib.
}
-(void)setup{
    [[_usernameTF rac_signalForControlEvents:UIControlEventEditingDidBegin] subscribeNext:^(__kindof UIControl * _Nullable x) {
        
    }];
}
-(void)bindModelView{
    RAC(self.LoginBtn,enabled) = self.viewModel.enableLoginSignal;
    RAC(self.viewModel,userName) = _usernameTF.rac_textSignal;
    RAC(self.viewModel,passWord) = _passwordTF.rac_textSignal;
}


- (IBAction)loginAction:(id)sender {
    __weak typeof(self) weakSelf = self;
    [[_viewModel.logincommand execute:nil] subscribeNext:^(id  _Nullable x) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:@"ds"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
